#pragma once

#ifndef DBOBJECTH_H_
#define DBOBJECTH_H_

#include <QtCore/QList>
#include <QtCore/QVariant>
#include <QtCore/QString>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlDatabase>

namespace SQLDoc
{
	/// <summary>
	/// Base class for all database objects (connections, databases, tables, etc.)
	/// </summary>
	class DBObject
	{
	public:
		DBObject(int objectType, QString name = QString(""), int id = -1);
		virtual ~DBObject(void);

		virtual Qt::CheckState checked() const;
		virtual void setChecked(Qt::CheckState val);
		void verifyCheckedState(Qt::CheckState childState);

		virtual int id() const;
		virtual void setId(int val);

		virtual QString name() const;
		virtual void setName(QString val);

		virtual QString comment() const;
		virtual void setComment(QString val);

		virtual int objectType() const;

		virtual DBObject *childItem(int row);
		virtual QList<DBObject*>& childItems();
		virtual int childCount() const;
		virtual void addChild(DBObject *child);

		virtual DBObject *parentItem() const;		

		enum DBObjectType
		{
			DBOTYPE_ROOT = 0,
			DBOTYPE_CONNECTION = 1,
			DBOTYPE_DATABASE = 2,
			DBOTYPE_TABLE = 3
		};

	protected:
		/* BEGIN - Private Members */
		Qt::CheckState m_checked;
		int m_id;
		int m_objectType;
		QString m_name;
		QString m_comment;
		QList<DBObject*> m_childItems;
		DBObject *m_parentItem;
		/* END - Members */

		void setParentItem(DBObject *parent);
		Qt::CheckState childrenCheckState(void);
	};
}

#endif
